package no.cicero.testframework.common.xml;

import org.xml.sax.Attributes;

public class XmlTag{
    private XmlTag parent = null;
    private String qualified_name = null;
    private XmlAttributes attributes = null;
    private IXmlImporterDelegate delegate = null;
    private int state = 0;

    public XmlTag(XmlTag p, String qn, Attributes a, IXmlImporterDelegate d){
        parent = p;
        this.qualified_name = qn;
        if(a != null)
            attributes = new XmlAttributes(a);
        delegate = d;
    }

    public XmlAttributes getAttributes() {
        return attributes;
    }
    
    public String getName() {
        final int index = qualified_name.indexOf(':');

        if( index == -1 ) {
            return qualified_name;
        }

        return qualified_name.substring( index + 1 );
    }

    public String getQualifiedName() {
        return qualified_name;
    }

    public XmlTag getParent() {
        return parent;
    }

    public IXmlImporterDelegate getDelegate() {
        return delegate;
    }    

    public void setDelegate(IXmlImporterDelegate delegate) {
        this.delegate = delegate;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }
    
}
    
